package ihm;

import java.awt.Graphics;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.swing.JFrame;

import controleur.Controleur;

public class IHM extends JFrame implements KeyListener {
	
	Controleur cont;
	AffichageMap affMap;
	
	public IHM(Controleur cont) {
		super("Projet 42");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		/** Ouvre en plein �cran **/
		setSize(800, 600);
		setDefaultLookAndFeelDecorated(false);
		setExtendedState(JFrame.MAXIMIZED_BOTH);
		
		this.cont = cont;
		addKeyListener(this);
		
		setVisible(true);
	}

	public void initMap(){
		affMap = new AffichageMap(cont);
		add(affMap);
	}
	@Override
	public void keyPressed(KeyEvent arg0) {
		if(arg0.getKeyCode() == KeyEvent.VK_Z)
			cont.getHero().deplacer('n');
		if(arg0.getKeyCode() == KeyEvent.VK_Q)
			cont.getHero().deplacer('o');
		if(arg0.getKeyCode() == KeyEvent.VK_S)
			cont.getHero().deplacer('s');
		if(arg0.getKeyCode() == KeyEvent.VK_D)
			cont.getHero().deplacer('e');
		if(arg0.getKeyCode()==KeyEvent.VK_C)
			new MenuJoueur(cont);
	}

	@Override
	public void keyReleased(KeyEvent arg0) {
	}

	@Override
	public void keyTyped(KeyEvent arg0) {
	}
	
}
